<extend name="Public/base" />
<block name="content">
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a href="{:U('Index/index')}" title="首页" class="tip-bottom"><i class="icon-home"></i> 首页</a> 
			<a href="#" class="current">{$meta_title}</a>
		</div>
	</div>
	<div class="container-fluid">
		<br/>
		<div class="search-form fr cf">
			<div class="sleft">
				<span class="control-group">
					<select class="form-control" style="width: 200px;" name="activity_id"  id="activity_id" onchange="change_present(activity_id)">
						<option value=0>选择活动</option>
						<volist name="activity_list" id="vo">
							<option value='{$vo.activity_id}'>{$vo.activity_name|strip_tags}</option>
						</volist>
					</select>
				</span>
				<span class="control-group">
					<select class="form-control" style="width: 200px;" name="present_id" id="present_id">
						<option value=0>选择礼品</option>
						<volist name="present_id_list" id="vo">
							<option value='{$key}'>{$vo|strip_tags}</option>
						</volist>
					</select>
				</span>
				<input type="text" name="paper_order" class="search-input span2" maxlength="11" value="{:strip_tags(I('paper_order'))}" placeholder="纸质订单号" style="margin-bottom:0;">
				<input type="text" name="mobile_phone" class="search-input span2" maxlength="11" value="{:strip_tags(I('mobile_phone'))}" placeholder="手机号" style="margin-bottom:0;">
				<button class="btn btn-info" id="search_button" url="{:U('OrderGift/index')}"><i class="icon-search icon-white"></i></button>
			</div>
		</div>
		<div class="row-fluid">
			<div class="span12">
				<div class="widget-box">
					<div class="widget-content ">
					<notempty name="_list">
						<form id="export-form" method="post" action="" autocomplete="off">
							<table class="table table-bordered table-striped with-check">
								<thead>
									<tr>
										<th nowrap="nowrap">序号</th>
										<th>礼品名称</th>
										<th>手机号</th>
										<th>活动</th>
										<th>换礼时间</th>
										<!-- <th>还礼时间</th> -->
										<!-- <th>礼品状态</th> -->
										<th>数量</th>
										<th>换礼详情</th>
									</tr>
								</thead>
								<tbody>
									<volist name="_list" id="vo">
										<tr>
											<td class="taskStatus">{$i}</td>
											<td class="taskStatus">{$vo.present_name}</td>
											<td class="taskStatus">{$vo.customer_id|getCustomerName|msubstr=###,0,11}</td>
											<td class="taskStatus">{$vo.activity_id|getActivityName|msubstr=###,0,40}</td>
											<td class="taskStatus">{$vo.change_time|time_format}</td>
											<!-- <td class="taskStatus">{$vo.back_time|time_format}</td> -->
											<!-- <td class="taskStatus">{$vo.status_text}</td> -->
											<td class="taskStatus">{$vo.gift_num|default='0'}</td>
											<td class="taskStatus"><a href="{:U('orderGiftInfo?gift_id='.$vo['gift_id'])}" class="btn btn-mini btn-info">详 情</a></td>
										</tr>
									</volist>
								</tbody>
							</table>
							<div class="control-group" style="text-align:right;">
								共：<span id="order_sum">{$_total|default='0'}</span> 单  
							</div>
							<div class="dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi ui-buttonset-multi paging_full_numbers" id="DataTables_Table_0_paginate">
								{$_page}
							</div>
						</form>
					<else/>
						<center>暂无内容</center>
					</notempty>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
/**
 * @todo 活动礼品联动
 * @param activity_id
 * @author sap
 */
function change_present(activity_id){
	var activity_id = parseInt($(activity_id).val());
	if(activity_id !== 0){
		$.post("{:U('OrderGift/getPresentId')}",{activity_id : activity_id},function(backData){
			//商户选项
			$('#present_id').empty();
			var option = '';
			option += '<option value="0">选择礼品</option>';
			if(backData.status == 1){
				$.each(backData.data,function(index,array){
					option += '<option value="'+index+'">'+array+'</option>';
				})
			}
			$('#present_id').append(option);
			set_value("present_id", 0);
		})
	}else{
		$('#present_id').empty();
		$('#present_id').append('<option value="0">选择礼品</option>');
		set_value("present_id", 0);
	}
}
//选择框默认选种状态
$(function (){
	set_value("activity_id",'{:I('activity_id',0)}')
	set_value("present_id",'{:I('present_id',0)}')
});
//导航高亮
highlight_subnav("{:U('OrderGift/index')}");
</script>
</block>